package gamePack.entities;

import gamePack.Controller;
import gamePack.Game;
import gamePack.Physics;
import gamePack.gfx.Animation;
import gamePack.gfx.ImageManager;

import java.awt.Graphics;
import java.awt.Rectangle;

public class PowerUp extends GameObject implements EntityA {

	private Game game;
	private Controller controler;
	private Physics fisica;
	private Animation powerUpAnim;
	private ImageManager im;

	public PowerUp(int x, int y, Game game, Controller c, ImageManager im,
			Physics fisica) {
		super(x, y);
		this.game = game;
		this.controler = c;
		this.fisica = fisica;
		this.im = im;
		powerUpAnim = new Animation(im.getPowerUp(), 500);
	}

	public void tick() {
		y = y + 2;
		if (y > game.getHeight())
			controler.removeEntity(this);
		if (fisica.safeCollision(this, game.getPlayer())) {
			afectarJugador();
			controler.removeEntity(this);
		}
	}

	public void render(Graphics g) {
		powerUpAnim.render(g, x, y, game.getTileSize(), game.getTileSize());
	}

	public void afectarJugador() {
		game.aumentarScore(10);
	}

	public Rectangle getBounds() {
		return new Rectangle(x, y, 32, 32);
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

}
